import { createApp } from "vue";
import App from "./App.vue";
import Hello from "./Hello.vue";

// 创建应用
const app = createApp(App);

app.component("Hello", Hello); //设置为全局组件

app.config.globalProperties.x = 777; //设置全局属性x
//写完下面4行在组件中使用x属性时就不会变红了
declare module "vue" {
  interface ComponentCustomProperties {
    x: number;
  }
}

//定义全局指令
app.directive("beauty", (element, { value }) => {
  element.innerText += value;
  element.style.color = "green";
  element.style.backgroundColor = "yello";
});

// 挂载应用
app.mount("#app");

//卸载应用
setTimeout(() => {
  app.unmount();
}, 2000);
